package abd.pr1.Interface;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class NuevoActorPersonajeWindow extends JFrame {

	private static final long serialVersionUID = 1L;

	private JComboBox actores;
	private JComboBox personajes;
	private JButton guardar;
	private JButton cerrar;

	public NuevoActorPersonajeWindow() {
		super();
		this.build();
		this.setSize(500, 500);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}

	private void build() {

		this.getContentPane().setLayout(new BorderLayout());

		JLabel actoresLabel = new JLabel("Actor");
		actores = new JComboBox();

		JLabel personajesLabel = new JLabel("Personaje");
		personajes = new JComboBox();

		JPanel datosPanel = new JPanel();

		datosPanel.add(actoresLabel);
		datosPanel.add(actores);
		datosPanel.add(personajesLabel);
		datosPanel.add(personajes);

		guardar = new JButton("Guardar");
		guardar.setActionCommand("guardar_actor_personaje");

		cerrar = new JButton("Cerrar");
		cerrar.setActionCommand("cerrar_actor_personaje");

		JPanel botones = new JPanel();
		botones.add(guardar);
		botones.add(cerrar);

		this.getContentPane().add(datosPanel, BorderLayout.NORTH);
		this.getContentPane().add(botones, BorderLayout.SOUTH);
	}

	public void addListener(ActionListener a) {
		guardar.addActionListener(a);
		cerrar.addActionListener(a);
	}

	@SuppressWarnings("unchecked")
	public void setActores(Object[] actores) {

		for (int i = 0; i < actores.length; i++) {
			this.actores.addItem(actores[i].toString());
		}
	}

	@SuppressWarnings("unchecked")
	public void setPersonajes(Object[] personajes) {

		for (int i = 0; i < personajes.length; i++) {
			this.personajes.addItem(personajes[i].toString());
		}
	}

	public String getActorSelected() {

		return this.actores.getSelectedItem().toString();

	}

	public String getPersonajeSelected() {

		return this.personajes.getSelectedItem().toString();

	}
}
